<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>经纪人登录</title>

    <link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="css/ecaps.min.css" rel="stylesheet">
    <!-- Javascripts -->
    <script src="../jquery/jquery.min.js"></script>
    <script src="../bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
    <!-- Page Container -->
    <div class="page-container">
        <!-- Page Inner -->
        <div class="page-inner login-page">
            <div id="main-wrapper" class="container-fluid">
                <div class="row">
                    <div class="col-sm-6 col-md-3 login-box">
                        <h4 class="login-title">登录帐户</h4>
                        <form id="form_account">
                            <div class="form-group">
                                <label for="exampleInputEmail1">手机号码</label>
                                <input type="text" class="form-control" id="managerPhone" name="managerPhone">
                            </div>
                            <div class="form-group">
                                <label for="exampleInputPassword1">密码</label>
                                <input type="password" class="form-control"  id="managerPassword" name="managerPassword">
                            </div>
                            <a href="javascript:accountbutton()" class="btn btn-default">登录</a>
                            <a href="manager-register.html" class="btn btn-primary">注册</a><br>
                            <!-- <a href="index.html" class="forgot-link">Forgot password?</a> -->
                        </form>
                    </div>
                </div>
            </div>
        </div><!-- /Page Content -->
    </div><!-- /Page Container -->

    <script>
        function accountbutton(){
            let account = $("#form_account").serialize();
            $.ajax({
                type: "get",
                url: "/gewu/manager/managerLogin",
                data: account,
                success: function (res) {
                    console.log(res);
                    if (res.code == 200) {
                        alert("登录成功！")
                         localStorage.setItem("brokerToken", res.content); 
                         window.location = "manager.html";
                    }
                    else if (res.code == "500") {
                        alert("账户或密码不能为空")
                    } 
                    else if (res.code == "400") {
                        alert("账户或密码错误")
                    }
                    else {
                        alert("用户不存在，请注册账号！")
                    }
                }
            })
        }
    </script>
    </body>
</html>
